package com.example.pceb.controller;

import com.example.pceb.VO.RegistrationAuditVO;
import com.example.pceb.result.Result;
import com.example.pceb.service.RegistrationAuditService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/audit")
public class RegistrationAuditController {

    @Autowired
    private RegistrationAuditService registrationAuditService;

    /**
     * 提交注册审核申请
     */
    @PostMapping("/submit")
    public Result<String> submitAudit(@RequestBody RegistrationAuditVO auditVO) {
        return registrationAuditService.submitAudit(auditVO);
    }

    /**
     * 审核注册申请
     */
    @PostMapping("/process")
    public Result<String> auditRegistration(
            @RequestParam Long auditId,
            @RequestParam Integer status,
            @RequestParam(required = false) String remark,
            @RequestParam String auditor) {
        return registrationAuditService.auditRegistration(auditId, status, remark, auditor);
    }

    /**
     * 获取待审核列表
     */
    @GetMapping("/pending")
    public Result<Object> getPendingAudits() {
        return registrationAuditService.getPendingAudits();
    }

    /**
     * 获取审核历史
     */
    @GetMapping("/history")
    public Result<Object> getAuditHistory() {
        return registrationAuditService.getAuditHistory();
    }

    /**
     * 获取所有审核记录（用于调试）
     */
    @GetMapping("/all")
    public Result<Object> getAllAudits() {
        return registrationAuditService.getAllAudits();
    }
} 